{% extends "templates/base.phtml" %}
{%block content%}
<div class="page-content-wrap">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-body">
                    <div class="col-sm-12 title-wrap">
                        <div class="col-sm-4 title pull-left">
                            <h3>优惠券活动</h3>
                        </div>
                        <div class="col-sm-8 pull-right">
                            <a href="admin/appcoupon/create" class="btn btn-primary pull-right">新建</a>
                        </div>
                    </div>
                    <div class="col-xs-12 content-wrap">
                        {%for coupon in page.items %}
                        <div class="content">
                            <div class="col-xs-4 img-wrap">
                                <img src="{{coupon.pic}}">
                            </div>
                            <div class="col-xs-5">
                                <h3>{{coupon.name}}</h3>
                                <p><label>活动介绍：</label><span>{{coupon.info}}</span></p>
                                <p><label>活动时间：</label><span>{{coupon.start}}到{{coupon.end}}</span></p>
                                <p><label>参与人数：</label><span>{{coupon.countCouponuser()}}</span></p>
                                <p><label>URL：</label><a href="http://userdev.i-yizhan.com/appcoupon/index/{{coupon.id}}">http://userdev.i-yizhan.com/appcoupon/index/{{coupon.id}}</a></p>
                            </div>
                            <div class="col-xs-3">
                                <div class="col-xs-12">
                                    <a href="admin/appcoupon/update/{{coupon.id}}" class="btn btn-primary">编辑活动</a>
                                </div>
                                <div class="col-xs-12">
                                    <a href="admin/appcoupon/card/{{coupon.id}}" class="btn btn-primary">编辑优惠券</a>
                                </div>
                                <div class="col-xs-12">
                                    <a href="admin/appcoupon/destory/{{coupon.id}}" class="btn btn-primary">优惠券核销</a>
                                </div>
                                <div class="col-xs-12">
                                    <button class="btn btn-danger"  onclick="deleteConfirm({{coupon.id}});">删除</button>
                                </div>
                            </div>
                        </div>
                        {%endfor%}
                    </div>
                    {% include 'include/page' with ['page':page,'cla':'pagination pagination-sm pull-right','url':'/admin/appcoupon/index?page='] %}
                </div>
            </div>
        </div>
    </div>
</div>
{%endblock%}
{%block end%}
<style type="text/css">
    .title-wrap{
        margin: 50px 0;
    }
    .title-wrap .btn{
        margin-left: 20px;
    }
    .content{
        margin-bottom: 15px;
        overflow: hidden;
    }
    .img-wrap{
        height: 140px;
        overflow: hidden;
    }
    .img-wrap img{
        width: 100%;
        height: auto;
    }
    .content h3{
        margin-bottom: 20px !important;
    }
    .content p{
        margin-bottom: 0px !important;
        line-height: 1.5em;
    }
    .content .btn{
        margin-bottom: 5px !important;
    }
</style>
<script type="text/javascript">
    function deleteConfirm(delete_id) {
        noty({
            text: '确定要删除此优惠券活动么?',
            layout: 'topRight',
            buttons: [
                {
                    addClass: 'btn btn-success btn-clean', text: '确定', onClick: function ($noty) {
                    $noty.close();
                    $.post('/admin/appcoupon/delete/' + delete_id, {}, function (result) {
                        noty({text: '删除成功', layout: 'topRight', type: 'success'}
                        );
                        location.reload();
                    });
                }
                },
                {
                    addClass: 'btn btn-danger btn-clean', text: '取消', onClick: function ($noty) {
                    $noty.close();
                }
                }
            ]
        })
    }
</script>
{%endblock%}